﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace NSATBPortal
{
    public partial class RunsJournalView : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void RunsGrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            int iIndex = e.NewEditIndex;

            string sRecID = RunsGrid.DataKeys[iIndex].Value.ToString();

            Response.Redirect("TestCaseDetail.aspx?Op=ResTestCase&ID=" + sRecID.Trim()
                            + "&ParentID=" + Request.QueryString["ID"].ToString());
        }

        protected void RunsGrid_Init(object sender, EventArgs e)
        {
            DataTable dtResults;
            int iID = int.Parse(Server.UrlDecode(Request.QueryString["ID"].ToString()));
            using (ATBSchemaDB objATBDB = new ATBSchemaDB())
            {
                dtResults = objATBDB.GetRunsJournalItemDetail(iID);
            }

            RunsGrid.DataSource = dtResults;
            RunsGrid.DataBind();
        }

        protected void RunsGrid_DataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    if(e.Row.Cells[2].Text.ToLower().Contains("pass"))
                        e.Row.Cells[2].BackColor = System.Drawing.Color.LightGreen;
                    else
                        e.Row.Cells[2].BackColor = System.Drawing.Color.LightPink;
                }
            }
            catch
            {
                //ErrorLabel.Text = ex.Message;
            }
        }

    }
}